package com.ruoyi.project.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.domain.ReqShedule;
import com.ruoyi.project.service.IReqSheduleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 需求进度Controller
 * 
 * @author ruoyi
 * @date 2025-04-06
 */
@RestController
@RequestMapping("/project/shedule")
public class ReqSheduleController extends BaseController
{
    @Autowired
    private IReqSheduleService reqSheduleService;

    /**
     * 查询需求进度列表
     */
    @PreAuthorize("@ss.hasPermi('project:shedule:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReqShedule reqShedule)
    {
        startPage();
        List<ReqShedule> list = reqSheduleService.selectReqSheduleList(reqShedule);
        return getDataTable(list);
    }

    /**
     * 导出需求进度列表
     */
    @PreAuthorize("@ss.hasPermi('project:shedule:export')")
    @Log(title = "需求进度", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReqShedule reqShedule)
    {
        List<ReqShedule> list = reqSheduleService.selectReqSheduleList(reqShedule);
        ExcelUtil<ReqShedule> util = new ExcelUtil<ReqShedule>(ReqShedule.class);
        util.exportExcel(response, list, "需求进度数据");
    }

    /**
     * 获取需求进度详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:shedule:query')")
    @GetMapping(value = "/{taskId}")
    public AjaxResult getInfo(@PathVariable("taskId") Long taskId)
    {
        return success(reqSheduleService.selectReqSheduleByTaskId(taskId));
    }

    /**
     * 新增需求进度
     */
    @PreAuthorize("@ss.hasPermi('project:shedule:add')")
    @Log(title = "需求进度", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReqShedule reqShedule)
    {
        return toAjax(reqSheduleService.insertReqShedule(reqShedule));
    }

    /**
     * 修改需求进度
     */
    @PreAuthorize("@ss.hasPermi('project:shedule:edit')")
    @Log(title = "需求进度", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReqShedule reqShedule)
    {
        return toAjax(reqSheduleService.updateReqShedule(reqShedule));
    }

    /**
     * 删除需求进度
     */
    @PreAuthorize("@ss.hasPermi('project:shedule:remove')")
    @Log(title = "需求进度", businessType = BusinessType.DELETE)
	@DeleteMapping("/{taskIds}")
    public AjaxResult remove(@PathVariable Long[] taskIds)
    {
        return toAjax(reqSheduleService.deleteReqSheduleByTaskIds(taskIds));
    }
}
